package com.whcoding.multithreading.thred;

import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @program: spring-boot-learning
 * @description: 使用线程池创建线程
 * @author: whcoding
 * @create: 2022-09-21 16:57
 **/
public class MyThreadCreatePool {

	public static void main(String[] args) {
		ThreadPoolExecutor executorOne = new ThreadPoolExecutor
				(5,
				5,
				1,
				TimeUnit.MINUTES,
				new ArrayBlockingQueue<Runnable>(20),
				new CustomizableThreadFactory("Thread-pool"));
		executorOne.execute(() -> {
			System.out.println("使用线程池创建线程");
		});
		//关闭线程池
		executorOne.shutdown();
	}
}
